<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no">
	<meta content="yes" name="apple-mobile-web-app-capable">
	<meta content="black" name="apple-mobile-web-app-status-bar-style">
	<title>找回密码</title>
    <script src="__JS__/zepto.min.js"></script>
    <link href="__CSS__/weui.min.css" rel="stylesheet">
	<link rel="stylesheet" href="__SaleManager__/stylesheets/index.css">
</head>
<style>
	.find_verfy	{
		background: #fff;
    		position: relative;
    		margin-top: 0.7rem;
	}
	.verfy_code_input input {
    float: left;
    width: 8.5rem;
    height: 100%;
    color: #999;
}

/* .verfy_code_input img {
    margin-left: 15px;
    flex: 2;
    padding: 10px 0;
    text-align: center;
    border: 1px solid #6db0e4;
    border-radius: 5px;
    background: #fff;
    color: #6db0e4;
} */
.sendCode_btn_1{
	    margin-left: 15px;
    flex: 2;
    text-align: center;
    border-radius: 5px;
    color: #6db0e4;
}
.sendCode_btn_1 img{
	     /* position: absolute; */
    right: -6.8rem;
    /* top: 0; */
    width: 7.125rem;
    height: 3.09375rem;
    text-align: center;
    border: 0.03125rem solid #27a0d4;
    color: #27a0d4;
    border-radius: 0.15625rem;
}
</style>
<body>
<header class = "all_header">
			<a class = "h_back h_back_1" data-back='1' href="javascript:void(0)"><img src="__SaleManager__/images/back_icon.png" alt=""></a>
			<span class = "h_title">找回密码</span>
			<a class = "h_add" href="javascript:void(0)"></a>
		</header>
	<div class="findPassWord_w">
		
		<div class="find_tel_w">
			<span class = "tel_icon"></span>
			<div class="weui-cell" style = "margin-left: 25px;">
        <div class="weui-cell__bd">
          <input class="weui-input find_tel" type="text" name='mobile' id='mobile' placeholder="请输入手机号码">
          
        </div>
       </div>
		</div>
		<!-- <div class="find_code_w">
			<span class = "code_icon"></span>
			<div class="weui-cell" style = "padding-left: 40px;">
        <div class="weui-cell__bd">
          <input class="weui-input find_code" type="text"  name='verifCode' id='verifCode' placeholder="请输入图形验证码">
        </div>
      </div>
      <div class="sendCode_btn_1">
      	<img src="{:U('verify')}" id="img"
                             onclick="this.src = '/Home/SaleManager/Login/verify/id/' + Math.random()" >
      </div>
		</div> -->
		<div class="find_code_w">
			<span class = "code_icon"></span>
			<div class="weui-cell" style = "padding-left: 40px;">
        <div class="weui-cell__bd">
          <input class="weui-input find_code" type="text"  name='code' id='code' placeholder="请输入6位验证码">
        </div>
      </div>
      <div class="sendCode_btn">
      	发送验证码
      </div>
		</div>
		<div class="find_password_c">
			<span class = "password_icon"></span>
			<div class="weui-cell" style = "margin-left: 25px;">
        <div class="weui-cell__bd">
          <input class="weui-input find_pwd" type="text" name='password'   id='password' placeholder="请输入密码">
        </div>
       </div>
		</div>

		<div class="login_btn_w">
			<a href="javascript:;" class="weui-btn modify_btn">修改密码</a>
		</div>

		<div class="js_dialog" id="find_tips_dialog" style="display: none;">
      <div class="weui-mask"></div>
      <div class="weui-dialog">
        <div class="weui-dialog__bd"></div>
        <div class="weui-dialog__ft">
            <a href="javascript:;" class="weui-dialog__btn weui-dialog__btn_primary find_btns">确 定</a>
        </div>
      </div>
    </div>
    <input type="hidden" id="uuid" value="{$uuid}">
    <include file="./Application/Home/View/default/SaleManager/layer/popup.html"/>
	</div>
	<script src = "__SaleManager__/js/index.js"></script>
	<script src = "__SaleManager__/js/androidback.js"></script>
</body>
<script>
var returnStatus;
var returnMsgstatus;
$(document).on('click','.sendCode_btn',function(){
	//校验手机号
	check=false;
	var tel = $(".find_tel").val();
	if(tel.trim().length == 0){
		$('.weui-dialog__bd').html('请输入手机号');
 		$('#confirm_dialog').css('display','block');
 		return false;
	}
	/* if (tel.trim().length != 0) {
		$.ajax({
		    url: "/Home/SaleManager/Login/code",
		   // type: 'POST',
		    data: {"vcode":$('#verifCode').val()},
		    async: false,
		    cache: false,
		   	dataType:"json",
		    success: function (returndata) {
			    	if (returndata.status == "0000") {
			    			check=true;
			    			$('.weui-dialog__bd').html(returndata.msg);
				 		$('#confirm_dialog').css('display','block');
			    	}else{
			    			$('.weui-dialog__bd').html('图形验证码错误');
				 		$('#confirm_dialog').css('display','block');
						check=false;
			    			return false;
			    	}
			},
	    error: function (returndata) {
	    		$('.weui-dialog__bd').html('网络繁忙');
	 		$('#confirm_dialog').css('display','block');
	    }
	});
	}else{
		$('.weui-dialog__bd').html('请输入手机号');
 		$('#confirm_dialog').css('display','block');
	} */
	/* if(check==false){
		return false;
	} */
		$.ajax({
		    url: "/Home/SaleManager/Login/code",
		   // type: 'POST',
		    data:'',
		    async: false,
		    cache: false,
		   	dataType:"json",
		    success: function (returndata) {
			    	if (returndata.code ==200) {
			    		$("#uuid").val(returndata.uuid);
			    	}else{
			    		$('.weui-dialog__bd').html('网络繁忙');
				 	$('#confirm_dialog').css('display','block');
			    	}
			},
	    error: function (returndata) {
	    		$('.weui-dialog__bd').html('网络繁忙');
	 		$('#confirm_dialog').css('display','block');
	    }
	});
	codess = $("#uuid").val();
	//获取验证码
	$.ajax({
	    url: "/Sms/SMSCode/gainCode/f/json/code/"+codess,
	    type: 'POST',
	    data: {'code':$("#code").val(),'mobile':$("#mobile").val()},
	    async: false,
	    cache: false,
	   	dataType:"json",
	    success: function (returndata) {
	    	//session失效
	   	 	returnStatus=returndata.code;
	   	 	returnMsgstatus= returndata.msg;
	   	 	if(returndata.code==1){
		   	 	$('.weui-dialog__bd').html(returndata.msg);
		   	 	$('#confirm_dialog').css('display','block');
	   	 		//$('.sendCode_btn').html('10分钟后重发');
		   	 	$('.sendCode_btn').attr('disabled', "disabled");
	            $('.sendCode_btn').css({'color': '#cccccc','background-color': '#eee', 'cursor': 'not-allowed'});
	            $('.sendCode_btn').html('重新获取(60)');
            var count = 1;
            $('.sendCode_btn').unbind("click");
            var i = setInterval(function () {
                if (count == 60) {
                    $('.sendCode_btn').attr('disabled', false);
                    $('.sendCode_btn').html('发送动态密码');
                    clearInterval(i);
                    $('.sendCode_btn').css({'color': '#fff', 'background-color': '#ff5b79', 'cursor': 'pointer'});
                } else {
                    $('.sendCode_btn').html('重新获取' + '(' + parseInt(60 - count) + ')');
                }
                count++;
            }, 1000);
	   	 	}
		   	if(returndata.code==0){
		   		$('.weui-dialog__bd').html(returndata.msg);
		 		$('#confirm_dialog').css('display','block');
	   	 	}
	    },
	    error: function (returndata) {
	    		$('.weui-dialog__bd').html(returndata.msg);
	 		$('#confirm_dialog').css('display','block');
	    }
	});
})

//修改密码按钮触发
$(document).on('click','.modify_btn',function(){
		var tel = $(".find_tel").val(),
				pwd = $(".find_pwd").val();

		if (tel.trim().length == 0) {
			$("#find_tips_dialog").show().find(".weui-dialog__bd").html("请输入手机号");
			return false;
		};
		if (pwd.trim().length == 0) {
			$("#find_tips_dialog").show().find(".weui-dialog__bd").html("请输入密码");
			return false;
		};

	//获取验证码
	$.ajax({
	    url: "/Sms/SMSCode/checkCode/f/json",
	    type: 'POST',
	    data: {'code':$("#code").val(),'mobile':$("#mobile").val()},
	    async: false,
	    cache: false,
	   	dataType:"json",
	    success: function (returndata) {
	   	 	returnStatus=returndata.code;
	   	 	returnMsgstatus= returndata.msg
	   	 	if(returndata.code==1){
	   	 		updatePassword(); //修改密码
	   	 	}
	   	 	if(returndata.code==0){
		   	 	$('.weui-dialog__bd').html(returndata.msg);
	     		$('#confirm_dialog').css('display','block');
	   	 	}
	    },
	    error: function (returndata) {
	    		$('.weui-dialog__bd').html(returndata.msg);
	 		$('#confirm_dialog').css('display','block');
	    }
	});
	//校验验证码
	
})
$(document).on('click','.weui-dialog__btn_primary',function(){
	$('#confirm_dialog').css('display','none');
});
function updatePassword(){
	$.ajax({
	    url: "",
	    type: 'POST',
	    data: {'code':$("#code").val(),'mobile':$("#mobile").val(),'password':$("#password").val()},
	    async: false,
	    cache: false,
	   	dataType:"json",
	    success: function (returndata) {
	    		$('.weui-dialog__bd').html(returndata.msg);
	 		$('#confirm_dialog').css('display','block');
	    },
	    error: function (returndata) {
	    		$('.weui-dialog__bd').html(returndata.msg);
	 		$('#confirm_dialog').css('display','block');
	    }
	});
}			
</script>
</html>